﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Grupo3.Scenes;
using Microsoft.Xna.Framework.Input;
using Grupo3.Objetos;

namespace Grupo3.Telas
{
    class Menu : SceneBase
    {
        Objeto2D menu;
        SpriteFont segoe_26;
        Color ColorSelection = Color.White;
        public int selection = 0;
        KeyboardState lastk, currentk;



        public override void Start()
        {
            menu = new Objeto2D(Game1.instancia.Content.Load<Texture2D>("menu"), new Vector2(0, 0));
            segoe_26 = Game1.instancia.Content.Load<SpriteFont>("SpriteFont1");
        }

        public override void Update(GameTime gameTime)
        {
            menu.Update(gameTime);
            lastk = currentk;
            currentk = Keyboard.GetState();


            if (currentk.IsKeyDown(Keys.Down) && lastk != currentk && selection < 1)
            {
                selection++;
            }
            else if (currentk.IsKeyDown(Keys.Up) && lastk != currentk && selection > 0)
            {
                selection--;
            }

            else if ((selection == 0) && (currentk.IsKeyDown(Keys.Enter)))
            {
                SceneManager.setScene(new Level());

            }

            else if ((selection == 1) && (currentk.IsKeyDown(Keys.Enter)))
            {
                Game1.instancia.Exit();
            }
        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            menu.Draw(spriteBatch);
            if (selection == 0)
            {
                spriteBatch.DrawString(segoe_26, "PLAY", new Vector2(20, 100), ColorSelection);
                spriteBatch.DrawString(segoe_26, "EXIT", new Vector2(50, 200), Color.Black);
            }

            else if (selection == 1)
            {
                spriteBatch.DrawString(segoe_26, "PLAY", new Vector2(50, 100), Color.Black);
                spriteBatch.DrawString(segoe_26, "EXIT", new Vector2(50, 200), ColorSelection);
            }

        }

        public override void Terminate()
        {

        }
    }
}
